<?php

class td_block_widget extends WP_Widget {
    var $td_widget_builder;

    var $td_block_id = 0; // this is changed by td_blockx_widget s

    function __construct() {
        $this->td_widget_builder = new td_widget_builder($this);
        //get block map
        $this->td_widget_builder->td_map(td_global_blocks::get_instance($this->td_block_id)->get_map());
    }

    function form($instance) {
        $this->td_widget_builder->form($instance);
    }

    function update($new_instance, $old_instance) {
        return $this->td_widget_builder->update($new_instance, $old_instance);
    }

    function widget($args, $instance) {
        //render the instance
        echo td_global_blocks::get_instance($this->td_block_id)->render($instance);
    }
}



class td_block1_widget extends td_block_widget {
    var $td_block_id = 1; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_block1_widget");'));




class td_block2_widget extends td_block_widget {
    var $td_block_id = 2; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_block2_widget");'));




class td_block3_widget extends td_block_widget {
    var $td_block_id = 3; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_block3_widget");'));




class td_block4_widget extends td_block_widget {
    var $td_block_id = 4; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_block4_widget");'));




class td_block5_widget extends td_block_widget {
    var $td_block_id = 5; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_block5_widget");'));



class td_social_widget extends td_block_widget {
    var $td_block_id = 'td_social'; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_social_widget");'));



class td_popular_cat_widget extends td_block_widget {
    var $td_block_id = 'td_popular_categories'; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_popular_cat_widget");'));



class td_ad_box_widget extends td_block_widget {
    var $td_block_id = 'td_ad_box'; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_ad_box_widget");'));


class td_slide_widget extends td_block_widget {
    var $td_block_id = 'td_slide'; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_slide_widget");'));



class td_authors_widget extends td_block_widget {
    var $td_block_id = 'td_authors'; // change only the block id, the rest is autogenerated
}

add_action('widgets_init', create_function('', 'return register_widget("td_authors_widget");'));
?>